<?php
/**
 * Created by PhpStorm.
 * User: alice
 * Date: 2015/12/28
 * Time: 12:26
 */

/**
 * Class Involved_CustomizeModel
 */

class Involved_CustomizeModel extends BaseModel{

    protected $table = 'customize';


    /**
     * 获取定制单列表
     * @param $is_self
     * @param $user_id
     * @return array
     * @author alice
     * @date 2016-2-15
     */
    public function GetCustomizeList($is_self,$page,$user_id)
    {
        $where = [];
        if($is_self == 1){
            $where['supplier_id'] = $user_id;
        }

        $offset = ($page-1) * HostEnum::PAGE_NUM;

        return  DB::table($this->table)
            ->select('product_name','spec','number','created','customize_id','supplier_id')
            ->where($where)
            ->skip($offset)->take(HostEnum::PAGE_NUM)
            ->get();

    }

    /**
     * 获取产品定制单列表
     * @param $customize_id
     * @return mixed
     * @author alice
     * @date 2016-2-19
     */
    public function GetProductCustomizeList($customize_id)
    {
        return  DB::table($this->table)
            ->select('supplier','price')
            ->where('customize_id',$customize_id)
            ->get();
    }

    /**
     * 获取定制数量
     * @param $supply_id
     * @return mixed
     * @author alice
     * @date 2016-2-25
     */
    public function GetCustomizeNum($supply_id)
    {
        return DB::table($this->table)
            ->where('supply_id', $supply_id)
            ->count();
    }

    /**
     * 获取定制列表
     * @param $supply_id
     * @return mixed
     * @author alice
     * @date 2016-2-25
     */
    public function GetCustomizeInfo($supply_id)
    {
        return DB::table($this->table)
            ->select('supplier','number')
            ->where('supply_id',$supply_id)
            ->get();
    }














}